/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number}
 */
var search = function (nums, target) {
  let start = 0, end = nums.length
  while (start <= end) {
    let m = Math.floor((start + end) / 2)
    if (nums[m] === target) {
      return m
    }
    if (nums[m] < target) {
      start = m + 1
    } else {
      end = m - 1
    }
  }
  return -1
};

console.log(search([-1,0,3,5,9,12], 9));